package com.itheima.manager.service;

import com.itheima.manager.dao.StudentDao;
import com.itheima.manager.domain.Student;

/**
 * @Author chris
 * @Date 2020/6/15 21:23
 */
public class StudentService {
    private StudentDao studentDao=new StudentDao();
    public boolean addStu(Student stu) {
        return studentDao.addStu(stu);
    }

    public boolean isExist(String id) {
        Student[] stus = studentDao.findAllStu();
        boolean flag=false;
        for (int i = 0; i < stus.length; i++) {
            if(stus[i]!=null&&stus[i].getID().equals(id)){
                flag=true;
                break;
            }

        }

        return flag;
    }

    public Student[] findAllStu() {

        return studentDao.findAllStu();
    }

    public void deleteStu(String id) {
        studentDao.deleteStu(id);
    }

    public void updateStu(Student stu) {
        studentDao.updateStu(stu);
    }
}
